import * as React from 'react';
import BaseLayout from './layouts/BaseLayout';
import { history } from './util';
import Routers from './router';

import './App.scss';
import { connect } from 'dva';
@connect()
class App extends React.PureComponent<any, object> {
    constructor(props: any) {
        super(props);
        const { dispatch } = this.props;
        history.listen(location => {
            let url = location.pathname;
            dispatch({ type: "menu/change", payload: { url } });
        })

    }
    public render() {
        const { dispatch } = this.props;
        let url = history.location.pathname;
        dispatch({ type: "menu/change", payload: { url } });
        return (
            <BaseLayout>
                <Routers history={history} />
            </BaseLayout>
        );
    }
}

export default App;
